const pinataApiKey = "f9df5e9ac781668fe6a2";
const pinataSecretApiKey = "1c42e7bbc3950d00397d75eb965d5356a98a3dd2b7d08403c241daf007650eef";
const axios = require("axios");
const fs = require("fs");
const FormData = require("form-data");
const pinFileToIPFS = async () => {
   const url = `https://api.pinata.cloud/pinning/pinFileToIPFS`;
   
   let data = new FormData();
   
   data.append("file", fs.createReadStream("./test.jpg"));
   
   const res = await axios.post(url, data, {
    maxContentLength: "Infinity", 
    headers: {
      "Content-Type": `multipart/form-data; boundary=${data._boundary}`,
      pinata_api_key: pinataApiKey, 
      pinata_secret_api_key: pinataSecretApiKey,
    },
  });
  console.log(res.data);
};

pinFileToIPFS();